# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Damir Perisa <damir.perisa@bluewin.ch>

pkgbase=openbabel
pkgname=(openbabel python-openbabel)
pkgver=3.1.1
pkgrel=2
pkgdesc="A library designed to interconvert between many file formats used in molecular modeling and computational chemistry"
arch=('x86_64')
url="https://openbabel.org/wiki/Main_Page"
license=('GPL')
makedepends=('cmake' 'eigen' 'wxgtk3' 'boost' 'python' 'swig' 'maeparser' 'rapidjson' 'coordgen')
source=("https://github.com/openbabel/openbabel/releases/download/openbabel-${pkgver//./-}/openbabel-$pkgver-source.tar.bz2")
sha256sums=('a6ec8381d59ea32a4b241c8b1fbd799acb52be94ab64cdbd72506fb4e2270e68')

prepare() {
  mkdir -p build
}

build() {
  cd build
  cmake ../openbabel-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config-gtk3 \
    -DRUN_SWIG=ON \
    -DPYTHON_BINDINGS=ON
  make

  # To split python bindings
  sed -i '/scripts.cmake_install.cmake/d' cmake_install.cmake
}

package_openbabel() {
  depends=('libxml2' 'libsm' 'coordgen')
  optdepends=('wxgtk3: GUI interface')

  cd build
  make DESTDIR="$pkgdir" install
}

package_python-openbabel() {
  depends=('python' 'openbabel')

  cd build/scripts
  make DESTDIR="$pkgdir" install
}
